package cn.itsy.dao;

import cn.itsy.pojo.SysFunction;
import cn.itsy.pojo.SysRole;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.ColumnMapRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Repository
public class Menudaoimpl implements Menudao {
    @Resource
    private JdbcTemplate jt;

    @Override
    public List<SysFunction> menulist(String sql) {
        List<SysFunction> query = jt.query(sql, new BeanPropertyRowMapper<SysFunction>(SysFunction.class));
        return query;
    }

    @Override
    public List<Map<String, Object>> rolelist(String sql) {
        List<Map<String, Object>> query = jt.query(sql, new ColumnMapRowMapper());
        return query;
    }

    @Override
    public List<SysFunction> role(String sql) {
        List<SysFunction> query = jt.query(sql, new BeanPropertyRowMapper<SysFunction>(SysFunction.class));
        return query;
    }

    @Override
    public void delete(String sql) {
        jt.update(sql);
    }

    @Override
    public void add(String sql) {
        jt.update(sql);
    }
}
